<script>
  var removeDuplicates = function(nums) {
    let flag;
    let len = nums.length;
    for(let i = 0; i < len; i++) {
      if (flag !== nums[i]) {
        flag = nums[i]
      } else {
        nums.splice(i, 1)
        len--;
        i--;
      }
    }
    console.log(nums.length, nums)
  };
</script>